package com.alibaba.citrus.cr.unified.inventory.functions.handler;

import com.google.common.collect.Maps;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @description:
 * @author: yuhw
 * @date: 2024年01月23日 16:00
 **/
@Component
public class AllocateOrderStatusHandlerManager implements InitializingBean {
    @Resource
    private List<AllocateOrderStatusHandler> allocateOrderStatusHandlers;

    private Map<String,AllocateOrderStatusHandler> allocateOrderStatusHandlerMap = Maps.newHashMap();

    @Override
    public void afterPropertiesSet() throws Exception {
        allocateOrderStatusHandlers.forEach(allocateOrderStatusHandler -> {
            allocateOrderStatusHandlerMap.put(allocateOrderStatusHandler.getType(),allocateOrderStatusHandler);
        });
    }

    public AllocateOrderStatusHandler getStatusHandler(String type){
        return allocateOrderStatusHandlerMap.get(type);
    }
}
